package com.xuliucar.car.presenter

import com.cangmaomao.lib.utils.create
import com.xuliucar.car.contract.SelectClassContract

class SelectClassPresenter(val view: SelectClassContract.View) : SelectClassContract.Presenter {

    override fun start() {
    }


    init {
        view.setPresenter(this)
    }

    override fun readClass() {
        val list: HashSet<String> = view.context().create("className").getStringSet("name", HashSet<String>()) as HashSet<String>
        if (list.isEmpty()) {
            list.add("默认分类")
        }
        view.classList(list)
    }

    override fun saveClass() {
        view.context().create("className").edit().putStringSet("name", view.getClassList()).apply()
    }
}